document.write('<script type="text/javascript" src="' + context
		+ '/resources/common/js/windowopen.js"></script>');
/**
 * 重构信息列表初始化后回调函数
 */
function callBackAfterList() {
	inithelper();
}

/**
 * 过滤掉非监理人员节点
 * 
 * @param {}
 *            node
 * @return {}
 */
function selfShowNodeDecide(node) {
	// alert(node.text + '<--->' + node.attributes.type + '<--->' +
	// node.attributes.rating);
	var rnt = true;

	if (node.attributes.type == 'user'
			&& (node.attributes.rating != 1 && node.attributes.rating != 2)) {
		rnt = false;
	}
	return rnt;
}

/**
 * 查看文档附件
 * 
 * @param {}
 *            id
 * @param {}
 *            name
 * @param {}
 *            time
 * @param {}
 *            type
 */
function annexView(id, name, time, type) {
	var title = '文件上传人：' + name + '&nbsp;&nbsp;上传时间：' + time;

	var url = context + '/system/annex/annexview.jsp?id=' + id + '&name='
			+ title + '&type=' + type + '&url=' + $(id).getAttribute('url');

	popwindow(url, '', 700, 500);
}

/**
 * 重构信息列赋值函数
 */
function renderTQJspListHeader(value, cellmeta, record, rowIndex, columnIndex,
		store) {
	var fieldName = cellmeta.getDataIndex(columnIndex);
	if (fieldName == 'NF_FILE') {
		var str = '';
		Ext.each(value, function(item) {
			var id = item.id;
			var name = record.data['NF_USERNAME'];
			var type = item.type;
			var time = formatTime(record.data['NF_TIME']);
			if (type == 'jpg') {
				var url = context + '/temp-store/' + item.folder + '/' + id
						+ '.data';

				str += '<div class="divn" style="width:70px;" title="查看图片" onClick="javascript:annexView(\''
						+ id
						+ '\', \''
						+ name
						+ '\', \''
						+ time
						+ '\', \''
						+ type
						+ '\');">'
						+ '<img item="img" url="'
						+ item.url
						+ '" id="'
						+ id
						+ '" style="cursor:hand;" width="64" height="64" src="'
						+ url + '"/></div>'
			} else if (type == "amr") {
				str += '<div class="divn" style="width:70px;" title="点击播放音频" onClick="javascript:annexView(\''
						+ id
						+ '\', \''
						+ name
						+ '\', \''
						+ time
						+ '\', \''
						+ type
						+ '\');">'
						+ '<img item="amr" url="'
						+ item.url
						+ '" id="'
						+ id
						+ '" '
						+ 'style="cursor:hand;" width="64" height="64" src="'
						+ context + '/app/file/images/amr.jpg"/></div>'

			} else if (type == "mp4") {
				str += '<div class="divn" style="width:70px;" title="点击播放视频" onClick="javascript:annexView(\''
						+ id
						+ '\', \''
						+ name
						+ '\', \''
						+ time
						+ '\', \''
						+ type
						+ '\');">'
						+ '<img item="mp4" url="'
						+ item.url
						+ '" id="'
						+ id
						+ '" '
						+ 'style="cursor:hand;" width="64" height="64" src="'
						+ context + '/app/file/images/mp4.jpg"/></div>'

			} else {
				str += '<div class="divn" style="width:70px;" title="下载文件" onclick="javascript:viewAnnex(\''
						+ id
						+ '\');">'
						+ '<img style="cursor:hand;" width="64" height="64" src="'
						+ context + '/app/file/images/file.png"/></div>'
			}
		});

		return str;
	} else if (fieldName == 'NF_QUESTION') {
		return '<div class="divn" style="width:190px;" title="' + value + '">'
				+ value + '</div>';
	} else if (fieldName == 'NF_GROUPNAME') {
		return '<div class="divn" style="width:100px;" title="' + value + '">'
				+ value + '</div>';
	} else if (fieldName == 'NF_TIME') {
		return formatTime(value);
	} else if (fieldName == 'SP') {
		var str = '<a href="javascript:handleEdit(\'' + record.data['NF_ID']
				+ '\');">编辑</a>';

		str += '&nbsp;<a href="javascript:handleDel(\'' + record.data['NF_ID']
				+ '\');">删除</a>';

		return str;
	}
	return value;
}

/**
 * 修改状态
 */
function handleEdit(id) {
	window.location.href = context + '/app/file/fileedit.jsp?id=' + id;
}

function handleDel(id) {
	createHidden('nfid', id);
	deleteTable('APP_NS_FILE', 'single', '-1', null, function() {
				storeReload(0, 5, 'filemanagelist', false)
			});
}